import instance from './axios'

/**
 * @description 获取用户信息
 * @returns Promise
 */
export const getUser = () => {
    return instance.get('/getuser')
}


/**
 * @description 添加用户
 * @param {*} data 
 * @returns Promise
 */
export const addUser = (data) => {
    return instance({
        url: '/addUser',
        method: 'post',
        data
    })
}

/**
 * @description 支付宝充值
 * @param {*} data 
 * @returns Promise
 */
export const payment = (data) => {
    return instance({
        url: '/payment',
        method: 'post',
        data
    })
}

/**
 * @description 根据id获取用户信息信息
 * @param {*} _id 
 * @returns Promise
 */
export const getUserinfo = (_id) => {

    return instance({
        url: '/getUserById',
        method: 'post',
        data: { _id }
    })
}

/**
 * @description 获取成功订单列表
 * @param {*} data 
 * @returns Promise
 */
export const getSuccess = (data) => {
    return instance.post('/getSuccess', { data })
}

/**
 * @description 获取手机验证码
 * @param {*} phone 
 * @returns Promise
 */
export const getPhoneCode = (phone) => {
    console.log(phone);
    return instance.post('/SmsRequest', { phone })
}


/**
 * @description 验证手机验证码
 * @param {*} data 
 * @returns Promise
 */
export const verify = (data) => {
    return instance.post('/verify', data)
}

/**
 * @description 再次验证是否正确
 * @param {*} data 
 * @returns Promise
 */
export const verifyCodeTow = (data) => {
    return instance.post('/reverifyCode', data)
}


/**
 * @description 设置密码
 * @param {*} data 
 * @returns Promise
 */
export const setPwd = (data) => {
    return instance.post('/setPayPwd', data)
}

/**
 * @description 获取订单详情
 * @param {*} data 
 * @returns Promise
 */
export const getOrderInfo = (data) => {
    return instance.get(`/order_details?ids=${data}`)
}

/**
 * @description 判断是否设置过支付密码
 * @param {*} data
 * @returns 
 */
export const getUserPayPwd = (data) => {
    console.log(data.id);
    return instance.get(`/isSetPayPwd?_id=${data.id}`)

}

/**
 * @description 支付
 * @param {*} _id 
 * @param {*} pwd 
 * @returns 
 */
export const VerifyPwd = (data) => {
    return instance.post('/VerifyPwd', data)
}

/**
 * @description 修改支付密码
 * @param {*} data 
 * @returns Promise
 */
export const ChangePayPwd2 = (data) => {
    return instance.post('/ChangePayPwd', data)
}